package com.cityos.android.mystudynestedscroll.ui.behavior

import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import androidx.coordinatorlayout.widget.CoordinatorLayout
import com.cityos.android.mystudynestedscroll.R
import com.cityos.android.mystudynestedscroll.common.utils.DisplayUtils
import com.google.android.material.tabs.TabLayout
import com.youth.banner.Banner

/**
 * @author hailong
 * @date 2024年03月14日 17:43
 *
 * You never know what you can do until you try !
 * ----------------------------------------------------------------
 */
class UcHomeHeaderTitleBehavior(context: Context? , attrs: AttributeSet?) : CoordinatorLayout.Behavior<FrameLayout>(context , attrs) {

    private val scrollMax = DisplayUtils.dp2px(context , 100f)
    private var dependencyView: View? = null


    override fun layoutDependsOn(parent: CoordinatorLayout , child: FrameLayout , dependency: View): Boolean {
        return dependency.id == R.id.uc_home_banner && dependency is Banner<* , *>
    }


    override fun onDependentViewChanged(parent: CoordinatorLayout , child: FrameLayout , dependency: View): Boolean {
        if (layoutDependsOn(parent , child , dependency)) {
            child.translationY = -dependency.translationY / 2
            return true
        }
        return false
    }


}